<?php
/**
 *	[在线客服(onlineservice.{modulename})] (C)2012-2099 Powered by old sea(27025011).
 *	Version: 1.0
 *	Date: 2012-6-14 09:57
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}
class plugin_onlineservice 
{
	//TODO - Insert your code here
	/**
	 * @Methods describe
	 * @return string type
	 */
	public function plugin_onlineservice()
	{
		//配置
		global $_G;
	
		//print_r($_G['plugin']['onlineservice']);
	}
	
	public function global_footer() 
	{
		//TODO - Insert your code here
		global $_G;
		$setting = $_G['cache']['plugin']['onlineservice']; //获取配置信息
		$position = $setting['position'];
		$title = $setting['title'];
		$o_title = str_replace("\n","<br/>",$setting['o_title']);
		$qqlist = $this->_explode($setting['qq']);
		$alwwlist = $this->_explode($setting['alww']);
		//$msnlist = $this->_explode($setting['msn']);
		//$skypelist = $this->_explode($setting['skype']);
		$qq = $alww = $msn = $skype = '';
		$qq .= $this->_html('qq',$qqlist);
		$alww .= $this->_html('alww',$alwwlist);
		$data = $qq.$alww;
		$style = ($position == 1) ? 'onlineservice:left_float' : 'onlineservice:right_float';
		include template($style);
		return $return;
	}
	
	public function _explode($str)
	{
		$array = array();
		$array = explode("\n", $str);
		$list = array();
		foreach ($array as $k => $v)
		{
			if(!empty($v))
			{
				$list[$k] = explode("|", $v);
			}
			else
			{
				return '';
			}
		}
		return $list;
	}
	
	public function _html($type,$array=array())
	{
		$str = '';
		if(is_array($array) && count($array)>=1)
		{
			switch($type)
			{
				case qq:
				foreach($array as $v) 
				{
					$str .= '<li class=odd><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin='.$v[0].'&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:'.$v[0].':42" title="'.$v[1].'"></a></li>';

				}
				break;
				case alww:
				foreach($array as $v) 
				{
					$str .= '<li><a target="_blank" href="http://amos.im.alisoft.com/msg.aw?v=2&uid='.$v['0'].'&site=cntaobao&s=1&charset=utf-8" ><img border="0" src="http://amos.im.alisoft.com/online.aw?v=2&uid='.$v['0'].'&site=cntaobao&s=1&charset=utf-8" alt="点击这里给我发消息" /></a></li>';
				}
				break;
				case msn:
				foreach($array as $v) 
				{
					$str .= '<li><a href="msnim:chat?contact='.$v['0'].'"><img width="30" height="30" border="0" src="http://im.live.com/Messenger/IM/Images/Icons/Messenger.Logo.gif"/></a></li>';

				}
				break;
				case skype:
				foreach($array as $v) 
				{
					$str .='<li><a href="callto://'.$v['0'].'"><img border="0" src="http://goodies.skype.com/graphics/skypeme_btn_small_green.gif"/></a></li>';

				}
				break;
				default:
				break;
			}
			return $str;
		}
		else
		{
			return '';
		}
	}
}

?>